<template>
  <div class="container">
    <el-dialog title="题目审核" :visible="check" width="30%" center :before-close="btnoff">
      <el-radio v-model="sh.operation" :label="1" style="height: 30px">通过</el-radio>
      <el-radio v-model="sh.operation" :label="2" style="height: 30px">拒绝</el-radio>
      <el-input
        ref="text"
        style="padding-bottom: 40px"
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="textarea"
        clearable
      ></el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="btnoff">取 消</el-button>
        <el-button type="primary" @click="centerDialogVisible">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '../../api/hmmm/questions'

export default {
  name: 'audit',
  props: {
    check: {
      type: Boolean,
      default: false
    },
    rowDifficultydegree: {
      type: Object,
      default: () => {}

    },
    sh: {
      type: Object,
      default: () => {}
    }
  },
  components: {},
  data () {
    return {
      radio: '',
      textarea: '' // 文本域
    }
  },
  created () {

  },

  // this.radio = this.sh.operation === '通过' ? 1 : 2

  methods: {
    btnoff () {
      console.log(this.sh.operation)
      this.$emit('update:check', false)
      this.showVideo = false
      this.$refs.text.clear()
    },
    async  centerDialogVisible () {
      if (!this.textarea.trim()) {
        this.$message({
          message: '请输入审核意见',
          type: 'warning',
          showClose: true,
          duration: 3000
        })
      } else {
        try {
          // choiceCheck({ id: this.sh.id,chkRemarks: this.textarea, chkState: this.radio })
          await choiceCheck({ id: this.rowDifficultydegree.id, chkRemarks: this.textarea, chkState: this.sh.operation })
          this.$message({
            message: '操作成功',
            type: 'success',
            showClose: true,
            duration: 3000
          })
          this.showVideo = false
        } catch (error) {
          console.log(error)
        }
      }
    }

  }
}

</script>

<style lang="less" scoped>
</style>
